<?php
/**
 * Search page controller
 *
 * @author Valery
 *
 */

class SearchController extends modules_default_controllers_ControllerBase
{
	protected $_bForLoggedUsersOnly = false;
	protected $_contentLayout = 'contentonly';

//----------------------------------------------------------------------------------------------------

	public function init()
	{
		parent::init();
		$this->view->title = 'Search';
	}

//----------------------------------------------------------------------------------------------------

	public function indexAction()
	{
		$words	= $this->_getParam('words');
		$tag	= $this->_getParam('tag');
		$page	= $this->_getParam('page', 1);

		$allFavoriteCategory	= models_FavoritecategoryMapper::getAll();

		if (isset($tag))
		{
			$results = models_CardMapper::findByTag($tag, $page);
		}
		else
		{
			$results = models_CardMapper::findByNamePart($words, $page);
		}

		$this->view->allFavoriteCategory	= $allFavoriteCategory['array'];
		$this->view->results = $results;
	}

//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------

}
